home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 July / EnigmA AMIGA RUN 09 (1996)(G.R. Edizioni)(IT)[!][issue 1996-07 & 08][EARSAN CD VIII].iso / earcd / util3 / grabkick.lha / GrabKick.a < prev    next >
Text File  |  1996-06-11  |  6KB  |  209 lines

  1. ;**** GrabKick.a ******************************************
  2.  
  3.     NOLIST
  4.     INCDIR    AINCLUDE:
  5.     INCLUDE    dos/dosextens.i
  6.     INCLUDE lvo.i
  7.     INCLUDE dos/dos.i
  8.     INCLUDE    exec/execbase.i
  9.     INCLUDE    workbench/startup.i
  10.     INCLUDE    workbench/workbench.i
  11.     INCLUDE    libraries/asl.i
  12.     LIST
  13.  
  14. ; Programmheader
  15. ;
  16. ;    Name:        GrabKick
  17. ;    Author:        SDI
  18. ;    Distribution:    PD
  19. ;    Description:    read Kickstart out of ROM and write it to file
  20. ;    Compileropts:    -
  21. ;    Linkeropts:    -
  22. ;    CLI-Parameter:    FILENAME
  23. ;
  24. ; vers    date   length
  25. ; 1.1   23.12.92  10612    : ANSI-C-Version made by Ralf Gruner
  26. ;
  27. ;    I used name and idea of this program, but not the ANSI-C code,
  28. ;    because Amiga-ROM functions need no program space: 10612 --> 880 byte
  29. ;    My program makes no output to user! It can fail at some positions,
  30. ;    but these fails are so seldom that error messages aren't neccessary!
  31. ;    The only needed error message (disk full) is made by system function.
  32. ; 1.2   07.08.95    880    : new calculation for Revisionnummer works around
  33. ;    calculation-error of MaxonC++
  34. ; 1.3   03.12.95    244    : made new with Maxon Assembler
  35. ; 1.4   04.12.95    236    : made shorter
  36. ; 1.5   10.12.95    228    : made shorter
  37. ; 1.6   19.12.95    300    : now also working from WorkBench
  38. ; 1.7   05.01.96    332    : included CLI parameter FILENAME, removed some bugs
  39. ; 1.8   10.02.96    508 : Asl-Requester on Workbench-start, new Icon
  40. ; 1.9   11.02.96    488 : made shorter, commented text
  41. ; 1.10  12.02.96    484 : made shorter
  42. ; 1.11  14.02.96    476 : CMPA.L #0,Ax replaced by MOVE.L Ax,D0
  43. ; 1.12  17.02.96    476 : BUG: Open_Mode is .L and not .W !
  44. ; 1.13  08.03.96    472 : a little bit shorter, tricky LibName method,
  45. ;    translated source to english
  46. ; 1.14  11.04.96    472 : overworked the source code, no new binary file
  47. ; 1.15  11.06.96    496 : removed a .L / .W error in name-creation, removed
  48. ;    libname trick, added version-string to ASL-Req. title
  49. ;**** Programm ********************************************
  50.  
  51.     SECTION "GrabKick",CODE
  52.     SUBQ.W    #1,D0
  53.     CLR.B    (A0,D0.W)        ;make C-string, last char is 0
  54.     MOVE.L    A0,D5                ;D5 - CLI parameter name
  55.     TST.W    D0        ;if only one char, no parameter is given
  56.     BNE.B    .start
  57.     MOVEQ    #0,D5                ;D5 - clear (no name given)
  58. .start    MOVEQ    #0,D7                ;D7 - clear (later StartupM)
  59.     MOVEA.L    4.W,A6
  60.     MOVEA.L    ThisTask(A6),A4
  61.     TST.L    pr_CLI(A4)        ;are we on WorkBench ?
  62.     BNE.B    .CLI
  63.     LEA    pr_MsgPort(A4),A0
  64.     JSR    _LVOWaitPort(A6)    ;wait for StartUp message
  65.     LEA    pr_MsgPort(A4),A0
  66.     JSR    _LVOGetMsg(A6)        ;get Message into D7
  67.     MOVE.L    D0,D7                ;D7 - WBStartUp message
  68. .CLI    LEA    KICKEND(PC),A2            ;A2 - KickStr-End
  69.     MOVEQ    #33,D0
  70.     LEA    DOSNAME(PC),A1
  71.     JSR    _LVOOpenLibrary(A6)    ;open dos.library
  72.     TST.L    D0            ;fatal Error : librarybase = 0?
  73.     BEQ.B    .goend            ;instead of BEQ.W ENDE (-2 Byte)
  74.     MOVEA.L    D0,A5                ;A5 - DosBase
  75.     TST.L    D7
  76.     BEQ.B    .NoWB
  77.     MOVEA.L    D7,A0
  78.     MOVEA.L    sm_ArgList(A0),A0    ;on WB-start get PROGDIR:
  79.     MOVE.L    A0,D0            ;instead of CMPA.L #0,A0 (-4 Byte)
  80. .goend    BEQ.W    ENDE
  81.     MOVE.L    (A0),D1            ;set PROGDIR as current
  82.     MOVEA.L    A5,A6
  83.     JSR    _LVOCurrentDir(A6)
  84. .NoWB    LEA    $01000000,A3        ;Kick-ROM End is every time same!!!
  85.     MOVE.L    -20(A3),D3            ;D3 - RomSize
  86.     SUBA.L    D3,A3                ;A3 - Romstart
  87.     MOVEQ.L    #0,D4
  88.     MOVE.W    12(A3),D4            ;D4 - Romvers
  89.     MULU    #1000,D4
  90.     ADD.W    14(A3),D4            ;D4 - Fullversion
  91. .LOOP                    ;calculate kick..... name
  92.     MOVE.L    D4,D2
  93.     DIVU    #10,D2            ;divide with ten
  94.     MOVEQ    #0,D4
  95.     MOVE.W    D2,D4            ;store in D4
  96.     SWAP    D2
  97.     ADD.B    D2,-(A2)        ;remainder into namefile
  98.     TST.W    D4
  99.     BNE.B    .LOOP
  100. ;end of loop                    ;D4 - not used
  101.     MOVEA.L    D5,A2                ;A2 - CLI name or
  102.     TST.L    D5
  103.     BNE.B    .GoOn
  104.     LEA    KICKSTR(PC),A2            ;A2 - kick.....
  105. .GoOn    MOVEQ    #0,D6                ;D6 - clear (later AslBase)
  106.     MOVEQ    #0,D5                ;D5 - clear (later Lock)
  107.     TST.L    D7            ;if not WB then overgo asl-requester
  108.     BEQ.B    Open
  109.     MOVEA.L    4.W,A6
  110. **1111**
  111. *    LEA    DOSNAME(PC),A1        ;ugly trick : overwrite dos. with asl.
  112. *    MOVE.L    #'asl.',(A1)        ;saves some bytes!
  113.     LEA    ASLNAME(PC),A1
  114. **1111**
  115.     MOVEQ    #37,D0
  116.     JSR    _LVOOpenLibrary(A6)    ;open asl.library
  117.     MOVE.L    D0,D6                ;D6 - AslBase
  118.     BEQ.B    Open            ;failed ?, then like CLI
  119.     MOVEA.L    D6,A6
  120.     MOVEQ    #ASL_FileRequest,D0
  121.     LEA    TAGITEM(PC),A0
  122.     JSR    _LVOAllocAslRequest(A6)    ;create Request-struct
  123.     MOVEA.L    D0,A4                ;A4 - FileRequester
  124.     TST.L    D0
  125.     BEQ.B    Open            ;failed ?, then like CLI
  126.     MOVEA.L    A4,A0
  127.     LEA    TAGITEM(PC),A1
  128.     JSR    _LVOAslRequest(A6)    ;call requester
  129.     TST.L    D0
  130.     BEQ.B    CLEANUP            ;failed?, end!!!, it's user-abort
  131.     MOVE.L    fr_Drawer(A4),D1
  132.     MOVEQ    #SHARED_LOCK,D2        ;share the directory lock
  133.     MOVEA.L    A5,A6
  134.     JSR    _LVOLock(A6)        ;get lock on directory
  135.     MOVE.L    D0,D5                ;D5 - Lock
  136.     BEQ.B    CLEANUP            ;failed?, end!!!, else it makes shit
  137.     MOVE.L    D5,D1
  138.     JSR    _LVOCurrentDir(A6)    ;make selected directory current
  139.     MOVEA.L    fr_File(A4),A2            ;A2 - asl name
  140. Open    MOVE.L    A2,D1            ;name parameter
  141.     MOVE.L    #MODE_NEWFILE,D2    ;mode parameter
  142.     MOVEA.L    A5,A6
  143.     JSR    _LVOOpen(A6)
  144.     MOVE.L    D0,D4                ;D4 - FileHandle
  145.     BEQ.B    CLEANUP
  146.                 ;quantity parameter D3 has already it's value
  147.     MOVE.L    D4,D1            ;filehandle parameter
  148.     MOVE.L    A3,D2            ;buffer parameter
  149.     JSR    _LVOWrite(A6)
  150.     MOVE.L    D0,D2                ;D2 - returnstate of Write
  151.     MOVE.L    D4,D1            ;filehandle parameter
  152.     JSR    _LVOClose(A6)
  153.     CMP.L    D3,D2            ;D2 != D3, then delete File
  154.     BEQ.B    CLEANUP
  155.     MOVE.L    A2,D1
  156.     JSR    _LVODeleteFile(A6)
  157. CLEANUP
  158.     MOVE.L    D5,D1
  159.     BEQ.B    .next
  160.     JSR    _LVOUnLock(A6)        ;free lock
  161. .next    TST.L    D6
  162.     BEQ.B    .clsdos
  163.     MOVE.L    A4,D0        ;instead oft CMPA.L #0,A4 (-4 Byte)
  164.     BEQ.B    .clsasl
  165.     MOVEA.L    A4,A0
  166.     MOVEA.L    D6,A6
  167.     JSR    _LVOFreeAslRequest(A6)    ;close filerequester
  168. .clsasl    MOVEA.L    4.W,A6
  169.     MOVEA.L    D6,A1
  170.     JSR    _LVOCloseLibrary(A6)    ;close asl.library
  171. .clsdos    MOVEA.L    4.W,A6
  172.     MOVEA.L    A5,A1
  173.     JSR    _LVOCloseLibrary(A6)    ;close dos.library
  174. ENDE
  175.     TST.L    D7            ;come we from Workbench ?
  176.     BEQ.B    .exit            ;no - was CLI
  177.  
  178.     JSR    _LVOForbid(A6)        ;make ReplyMsg save
  179.     MOVEA.L    D7,A1            ;get Message into A1
  180.     JSR    _LVOReplyMsg(A6)    ;end program
  181.  
  182.     MOVEQ    #0,D0
  183. .exit    RTS    
  184. DOSNAME    DC.B    'dos.library',0
  185. **1111**
  186. ASLNAME    DC.B    'asl.library',0
  187. **1111**
  188. KICKSTR    DC.B    'kick00000'
  189. KICKEND    DC.B    0
  190. TAGITEM    DC.L    ASLFR_InitialFile,KICKSTR
  191. **2222**
  192.     DC.L    ASLFR_TitleText,VERSION
  193. **2222**
  194.     DC.L    0
  195.     DC.B    '$VER: '
  196. VERSION    DC.B    'GrabKick 1.15 (11.06.96) (PD) by SDI'
  197. **2222**
  198.     DC.B    0
  199. **2222**
  200.     ; 0 byte of the string is not needed, because in the file the header
  201.     ; does same as a 0 byte and in running state the string isn't used
  202.  
  203. * in the lines between **....** remove stars and set stars to the lines
  204. * without, for:
  205. * **1111** : remove the ugly asl.library name trick
  206. * **2222** : set ASL titletext to programname (needs 12 bytes more)
  207.     END
  208.  
  209.